﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace CRMSalesManagement.FrontPageShow
{
    public partial class ProductInforList : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int pageNum = 1;
                if (Request.QueryString["page"] != null)
                {
                    pageNum = int.Parse(Request.QueryString["page"]);
                }
                int total = 0;
                IList<CRM.Model.ProductSearchResult> columnDb = null;
                if (Session["searchContent"].ToString() == "")
                {
                    columnDb = CRM.Business.Product.PageListProducts(out total, pageNum, this.DataPage1.ShowRecordCount);
                }
                else
                {
                    columnDb = CRM.Business.Product.PageListProducts(out total, pageNum, this.DataPage1.ShowRecordCount, Session["searchType"].ToString(), Session["searchContent"].ToString());
                }
                // var columnDb = CRM.Business.Product.PageListProducts(out total, pageNum, this.DataPage1.ShowRecordCount);
                this.DataPage1.TotalRecordCount = total;
                this.DataPage1.ShowPageNumberCount = pageNum;
                if (columnDb != null)
                {
                    this.gvProductsList.DataSource = columnDb;
                    this.gvProductsList.DataBind();
                    if (this.DataPage1.TotalRecordCount == 0)
                    {
                        lblProduct.Text = "*暂无信息";
                        lblProduct.Visible = true;
                    }
                    else
                    {
                        lblProduct.Visible = false;
                    }
                }

                #region 控制分页控件
                CRM.Business.ShowPageDispaly.PageDispaly(this.DataPage1, pageNum, total);
                #endregion
            }
        }

        protected void gvNewsList_RowEditing(object sender, GridViewEditEventArgs e)
        {
            //Session["productInforId"] = Convert.ToInt32(gvProductsList.DataKeys[e.NewEditIndex].Value);
            Response.Redirect("/FrontPageShow/ProductInformation.aspx?productInforId=" + Convert.ToInt32(gvProductsList.DataKeys[e.NewEditIndex].Value));
        }
    }
}